﻿using JTTD.Domain.IService;
using JTTD.Domain.Service;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Redis;
using Microsoft.Extensions.DependencyInjection;

namespace JTTD.Extensions
{
    /// <summary>
    /// 服务拓展
    /// </summary>
    public static class ServiceCollectionExtensions
    {
        /// <summary>
        /// 添加服务映射
        /// </summary>
        /// <param name="services"></param>
        public static void AddCoreServices(this IServiceCollection services)
        {
            //Session存于redis中
            services.AddScoped<IDistributedCache>(
                serviceProvider =>
                    new RedisCache(new RedisCacheOptions
                    {
                        Configuration = "127.0.0.1",
                        InstanceName = "Session:"
                    }));
            services.AddTransient<IActivityService, ActivityService>();
            services.AddTransient<ICompanyUserInfoService, CompanyUserInfoService>();
            services.AddTransient<IConfigService, ConfigService>();
            services.AddTransient<ICouponService, CouponService>();
            services.AddTransient<IIntegralService, IntegralService>();
            services.AddTransient<IUserInfoService, UserInfoService>();
            services.AddTransient<IWeiXinService, WeiXinService>();
            services.AddTransient<IShopActivityService, ShopActivityService>();
            services.AddTransient<IShopCouponService, ShopCouponService>();
            services.AddTransient<ICompanyBillService, CompanyBillService>();
        }
    }
}
